12. Errors and Exceptions

Which of the following statements are true? (Check all that apply.)

SOLUTION:
  • Any syntax error can be detected before running your program.
  • An exception occurs during run time.
  • There are many types of exceptions.

QUIZ QUESTION::

Here are some of the common exceptions programmers run into in Python. Do some research online to match the appropriate description for each.

ANSWER CHOICES:



Built-in Exception

Description

A key can't be found in a dictionary.

A sequence subscript is out of range.

An object of an unsupported type is passed as input to an operation or function.

An object of the correct type but inappropriate value is passed as input to a built-in operation or function.

An assert statement fails.

SOLUTION:

Built-in Exception

Description

A key can't be found in a dictionary.

A sequence subscript is out of range.

An object of an unsupported type is passed as input to an operation or function.

An object of the correct type but inappropriate value is passed as input to a built-in operation or function.

An assert statement fails.